#ifndef SCOPEDWRITER_H
#define SCOPEDWRITER_H

#include <iostream>
#include <string>

using namespace std;


class ScopedWriter {
public:
	ScopedWriter(const char * header, bool enabled = true) {
		enabled_ = enabled;

		if (!enabled_)
			return;

		s = header;
		/*cout << "/ " << header << "\\\n";
		cout.flush();*/
	}

	~ScopedWriter() {
		if (!enabled_)
			return;

		/*cout << "\\ END /\n";
		cout.flush();*/
	}

	template <typename T>
	ScopedWriter & operator << (const T & t) {
		if (!enabled_)
			return *this;

		cout << t;
		cout.flush();
		return *this;
	}

private:
	bool enabled_;
	string s;
};

#endif // SCOPEDWRITER_H
